package com.yan.lambda;

/**
 * @author taoge
 * @Date 2024/8/15 16:03
 * @Description
 */
public class Demo1 {
    public static void main(String[] args) {
        NoReturnNoparam noReturnNoParam = () -> System.out.println("无参无返回值方法");
        noReturnNoParam.method();

        NoReturnOneParam noReturnOneParam = a -> System.out.println("有一个参数无返回值方法" + a);
        noReturnOneParam.method(10);

        NoReturnMutipleParam noReturnMutipleParam = (a, b) -> System.out.println("有多个参数无返回值方法" + a + b);
        noReturnMutipleParam.method(10 , "asd");

        ReturnNoParam returnNoParam = () -> {
            System.out.println("无参有返回值方法");
            return 10;
        };
        int method = returnNoParam.method();
        System.out.println(method);

        ReturnOneParam returnOneParam = a -> Integer.parseInt(a + 10);
        int method1 = returnOneParam.method("1");
        System.out.println(method1);

        ReturnMutipleParam returnMutipleParam = (name, age) -> {
            System.out.println("名字是" + name);
            return age;
        };

        int method2 = returnMutipleParam.method("yft", 18);
        System.out.println(method2);
    }
}

@FunctionalInterface
interface NoReturnNoparam{
    void method();
}

@FunctionalInterface
interface NoReturnOneParam{
    void method(int a);
}

@FunctionalInterface
interface NoReturnMutipleParam{
    void method(int a , String b);
}

@FunctionalInterface
interface ReturnNoParam{
    int method();
}

@FunctionalInterface
interface ReturnOneParam{
    int method(String name);
}

@FunctionalInterface
interface ReturnMutipleParam{
    int method(String name , int age);
}
